//
// Created by fengg on 2020/3/25.
//

#include <iostream>
#include <cstdlib>
namespace Aho{
    template<class T,size_t MAXSIZE>
    class Stack{
    private:
        T *stack;
        int top;
    public:
        Stack(){
            stack = (T *) malloc(sizeof(T)*MAXSIZE);
            top = -1;
        }
        ~Stack(){
            free(stack);
        }
        int push(T value){
            if (top >= MAXSIZE-1)
                return 1;
            stack[++top];
            return 0;

        }

        T pop(){
            if(top >= 0)
                return stack[top--];
        }
        T head(){
            if(!isEmtpy()){
                return this->stack[this->top];
            }
            
        }
        bool isEmtpy(){
            return top < 0;
        }

    };
}

char operators[] = "+-*/()";
int operators_level[] = {0,0,1,1,2,2};
enum operators_index {
    plus = 0,
    sub,
    times,
    divs,
    lparen,
    rparen
};

double evaluate(const char *raw){
    Aho::Stack<int ,50> number_stack;
    Aho::Stack<char,50> op_stack;
    Aho::Stack<char,50> op_stack_f;

    int temp_int = 0;
    bool match = false;
    for (int i = 0;raw[i]!=0; ++i) {
        if(isdigit(raw[i]))
            temp_int = temp_int*10+raw[i]-'0';
        else{
            number_stack.push(temp_int);
            temp_int = 0;
            for (int j = 0; operators[j]!=0; ++j) {
                if(operators[i] == raw[i]){
                    match = true;
                    break;
                }
            }
            if(match){
                if(op_stack.head())
                op_stack.push(raw[i]);
            }
            match = false;
        }
    }
}

int main(){

    return 0;
}